package com.example.instrument.controller;

import com.example.instrument.service.InstrumentService;
import com.example.instrument.vo.InstrumentVo;
import com.example.result.CommonResult;
import com.example.utils.MyPageHelper;
import com.example.utils.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("instrument")
public class InstrumentController {
    @Autowired
    InstrumentService instrumentService;
    /**
     * 收费管理-仪表全查
     * @return
     */
    @GetMapping("/getInstrument")
    public CommonResult getInstrument(@RequestParam String instrumentName, PageRequest pageRequest){
        MyPageHelper.StartPage(pageRequest);
        CommonResult commonResult = instrumentService.getInstrument(instrumentName);
        return commonResult;
    }

    /**
     * 收费管理-仪表删除
     */
    @DeleteMapping("/delInstrument")
    public CommonResult delInstrument(Integer id){
        int i = instrumentService.delInstrument(id);
        return CommonResult.ok(i);
    }
    /**
     * 收费管理-仪表增改
     */
    @PostMapping("/saveOrUpdateInstrument")
    public CommonResult saveOrUpdateInstrument(@RequestBody InstrumentVo instrumentVo){
        CommonResult commonResult = instrumentService.saveOrUpdateInstrument(instrumentVo);
        return commonResult;
    }
}
